package com.hundsun.cprs.yyt.util;

import java.util.HashMap;
import java.util.Map;

/**
 * 项目计价单位,Eg: 元,万元,亿元,
 * 
 * @author linbo
 * 
 */
public enum EnumValuationUnit {
	FEN("fen", "分", 1L, 0), 
	JIAO("jiao", "角", 10L, 1), 
	YUAN("yuan", "元", 100L, 2), 
	WANYUAN("wanyuan", "万元", 1000000L,	6), 
	YIYUAN("yiyuan", "亿元", 10000000000L, 10);

	private String value;

	private String name;

	/**
	 * 以分为基础的比率
	 */
	private Long rate;

	/**
	 * 小数点位数
	 */
	private int scale;

	/**
	 * 全局索引池
	 */
	private static Map<String, EnumValuationUnit> pool = new HashMap<String, EnumValuationUnit>();
	static {
		for (EnumValuationUnit et : EnumValuationUnit.values()) {
			pool.put(et.value, et);
		}
	}

	/**
	 * 根据内容索引
	 * 
	 * @param value
	 * @return
	 */
	public static EnumValuationUnit indexByValue(String value) {
		return pool.get(value);
	}

	private EnumValuationUnit(String value, String name, Long rate, int scale) {
		this.value = value;
		this.name = name;
		this.rate = rate;
		this.scale = scale;
	}

	public String getValue() {
		return value;
	}

	public String getName() {
		return name;
	}

	public Long getRate() {
		return rate;
	}

	public int getScale() {
		return scale;
	}

}